import Vue from 'vue'
import Vuex from 'vuex'
import getters from './store/getters'
import createVuexAlong from 'vuex-along'

Vue.use(Vuex)

// S =
const modulesFiles = require.context('./store/modules', true, /\.js$/)
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
  const value = modulesFiles(modulePath)
  modules[moduleName] = value.default
  return modules
}, {})

// E =

export default new Vuex.Store({
  modules,
  getters,
  plugins: [createVuexAlong({
    name: 'tinkaikin', // 设置保存的集合名字，避免同站点下的多项目数据冲突
    local: {
      list: [''],
      isFilter: false // 过滤模块 ma 数据， 将其他的存入 localStorage
    },
    session: false

  })]
})
